/*
 * This file is part of WebCL – JavaScript bindings for OpenCL
 * http://webcl.nokiaresearch.com/
 *
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
 *
 * Contact: Jari Nikara  ;jari.nikara@nokia.com;
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1 as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 *
 * The package is based on a published Khronos OpenCL 1.1 Specification,
 * see http://www.khronos.org/opencl/.
 *
 * OpenCL is a trademark of Apple Inc.
 */

/** \interface IWebCLProgram
 * IWebCLProgram interface abstracts a WebCL program.
 * \see cl_program
 */

#include "nsISupports.idl"
#include "nsISecurityCheckedComponent.idl"
#include "nsIVariant.idl"

#include "WebCL_types.idl"

interface IWebCLDevice;
interface IWebCLKernel;

[scriptable, uuid(74d49a1e-31e0-41d5-8e98-8980a077fcb2)]
interface IWebCLProgram : nsISecurityCheckedComponent
{
  /** Get program info.
   * \param aName Name of the info parameter.
   * \return The resulting value.
   * \see clGetProgramInfo
   * \see WebCL_types
   */
  [implicit_jscontext]
  nsIVariant getProgramInfo (in long aName);

  /** Get program build info.
   * \param aDevice A WebCLDevice instance for which build information is
   *  being queried. Must be a valid device associated with the program instance.
   * \param aName Name of the info parameter.
   * \return The resulting value.
   * \see clGetProgramBuildInfo
   * \see WebCL_types
   */
  [implicit_jscontext]
  nsIVariant getProgramBuildInfo (in nsISupports aDevice, in long aName);

  /** Builds (compiles and links) a program executable from the program
   * source or binary.
   * \param aDevices Array of IWebCLDevice instances.
   * \param aOptions A string that describes the build options to be
   *  used for building the program executable.
   * \see clBuildProgram
   */
  [implicit_jscontext]
  void buildProgram (in nsIVariant aDevices,
                     in string aOptions);

  /** Creates a kernel object.
   * \param aKernelName A function name in the program declared with
   *  the __kernel qualifier.
   * \return A WebCLKernel instance.
   * \see clCreateKernel
   */
  [implicit_jscontext]
  IWebCLKernel createKernel (in string aKernelName);

  /** Creates kernel objects for all kernel functions in a program object.
   * \return Array of IWebCLKernel instances.
   * \see clCreateKernelsInProgram
   */
  [implicit_jscontext]
  nsIVariant createKernelsInProgram ();

  /** Immediately releases all OpenCL-related resources if any are allocated
   * for this object. The object should not be used anymore after calling
   * this function.
   */
  void releaseCLResources ();
};
